<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
</head>

<body>
  <div>
  </div>

  <script>

    // uTools API onPluginEnter(callback)
    // type 为 "files" 时， payload 值示例
    // [
    //   {
    //     "isFile": true,
    //     "isDirectory": false,
    //     "name": "demo.js",
    //     "path": "C:\\demo.js"
    //   }
    // ]
    utools.onPluginEnter(({ code, type, payload, option }) => {

      if (type === 'files' && payload) {
          const fpath = payload[0].path;
          let openshell = 'open -a "Sublime Text" ' + fpath;
          customApis.runshell(openshell);
          utools.outPlugin();
      }

    });
  </script>
</body>

</html>